package com.rds.document.service.impl;

import com.amazonaws.services.s3.model.PutObjectResult;
import com.rds.common.annotation.DataScope;
import com.rds.common.constant.S3Constants;
import com.rds.common.core.controller.BaseController;
import com.rds.common.core.domain.entity.Document;
import com.rds.common.core.domain.entity.DynamicVo;
import com.rds.common.core.domain.entity.File;
//import com.rds.common.core.domain.entity.SysDocument;
import com.rds.common.core.mapper.DynamicMapper;
import com.rds.common.core.service.impl.DynamicServiceImpl;
import com.rds.common.exception.CustomException;
import com.rds.common.utils.DateUtils;
import com.rds.common.utils.SecurityUtils;
import com.rds.common.utils.StringUtils;
import com.rds.common.utils.file.FileS3UploadUtils;
import com.rds.common.utils.uuid.SnowFlakeUtils;
import com.rds.document.domain.RdaFolderRel;
import com.rds.system.mapper.DocumentMapper;
import com.rds.system.mapper.FolderMapper;
import com.rds.document.mapper.RdaFolderRelMapper;
import com.rds.document.mapper.RdaLibraryMapper;
import com.rds.system.mapper.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.FileCopyUtils;

import java.io.FileInputStream;
import java.util.*;

/**
 * 文档管理--Service实现类
 * @author rds
 * @updater libin
 * @updateDate : 2024-2-19
 */
@Service
public class DocumentServiceImpl
{
    @Autowired
    private DynamicMapper dynamicMapper;
    /***
     * 根据文档id 查询生效状态的文件附件对象
     * @param docId 文档id
     * @return 文件附件对象
     */
    public List<HashMap<String,Object>> selectFileList(Long docId) {
        DynamicVo fileDynamicVo=new DynamicVo();
        fileDynamicVo.setTableName("rda_file");
        ArrayList<String> fileQueryWrapper=new ArrayList<>();
        fileQueryWrapper.add("and doc_id="+docId);
        fileQueryWrapper.add("and status=1");
        fileDynamicVo.setQueryWrapper(fileQueryWrapper);
        fileDynamicVo.setOrderBy(" order by create_time desc");
        return dynamicMapper.selectList(fileDynamicVo);
    }
}
